package com.utils;



import org.springframework.core.convert.converter.Converter;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringToDateConverter implements Converter<String,Date> {

    @Override
    public Date convert(String source) {
        if (source==null){
            throw new RuntimeException("请你输入数据");
        }
        DateFormat dateFormat=new SimpleDateFormat("yyyy-mm-dd");
        try {
            return dateFormat.parse(source);
        } catch (ParseException e) {
            throw new RuntimeException("数据类型转换出现问题！");
        }
    }

}
